package hashset;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @Author admin
 * @Date 2019/4/2 16:52
 */
public class Random {
    public static void main(String[] args) {
        HashSet<Integer> hashSet = new HashSet<Integer>();
        while (hashSet.size()<10){
            int n =(int)(Math.random()*40);
            hashSet.add(n);
        }
        /*Integer类中重写了equals方法，所以自动保存了不重复*/
        Iterator iterator = hashSet.iterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next()+"\t");
        }
    }
}
